﻿@{
    Layout = null;
    Dictionary<string, string> attachfiles = ViewData["attachfiles"] == null ? new Dictionary<string, string>() : ViewData["attachfiles"] as Dictionary<string, string>;
}
@model ElingOA6_Admin_DSJCJ.Model.FTP
<!DOCTYPE html>
<html>
<head>
    <title>文件查看</title>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
        <script src="../../../../Scripts/json2.js" type="text/javascript"></script>  
    }
    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    @Html.DevExpress().GetStyleSheets(

    new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }

    )
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox },
        new Script { ExtensionType = ExtensionType.UploadControl }
    )
    <link href="@Url.Content("~/Content/upload.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {

            var hdjsAlert = $("#hdjsAlert").val();


            if (hdjsAlert != "") {
                alert(hdjsAlert);
            }
            if (hdjsAlert == "修改成功") {

                window.location.href = '@Url.Content("~/Admin/FTPManage/")';

            }
        });
        function sub() {
            if ($("#FSubject").val() == null | $("#FSubject").val() == "") {
                alert("主题不能为空");
            }
            else {
                form_query.submit();
            }
        }

        function col() {
            window.location.href = '@ViewData["tourl"]';
        }


        function addFileControl(rowIndex) {
            var trLenth = $("#tableAttach tr[name='trAttach']").length;
            var lastTrId = $("#tableAttach tr[name='trAttach']")[trLenth - 1].id;
            if (lastTrId == "trAttach" + rowIndex) {
                rowIndex = rowIndex + 1;
                var uploadCtl = $("#hdUploadCtl").val();
                uploadCtl = uploadCtl.replace("addFileControl(_index_)", "addFileControl(" + rowIndex + ")");
                uploadCtl = uploadCtl.replace(new RegExp("uploadName", "gm"), "uploadName" + rowIndex);
                $("#tableAttach").append("<tr name='trAttach' id='trAttach" + rowIndex + "'>"
                                + "<td style='width: 10%; text-align:right'><a href='###' style='color:Red; font-size:12px' onclick='delFileControl(" + rowIndex + ")'>[删除]</a></td> "
                                + "<td style='width:30%'>" + uploadCtl + "</td>"
                //+ "<input type='file' id='fileUpload" + rowIndex + "'  name='attachUpload' onchange='addFileControl(" + rowIndex + ")'/>"
                                + "<td style='width:60%'>"
                                + "</td></tr>");
            }
        }
        function dellink(index) {
            if (confirm("确认删除文件?")) {
                var ids = JSON.parse($("#haids").val());
                $("#tblink tr[id='links" + index + "']").remove();
                // ids.splice(index - 1, 1);
                ids[index - 1] = "empty";
                $("#haids").val(JSON.stringify(ids));
                //  alert($("#haids").val());
            } 
        }
        /*删除上传附件控件*/
        function delFileControl(rowIndex) {
            var trLenth = $("#tableAttach tr[name='trAttach']").length;
            if (trLenth == 1) {
                //最后一行
                $("tr[id='trAttach" + rowIndex + "']").remove(); //删除当前行
                var uploadCtl = $("#hdUploadCtl").val();
                uploadCtl = uploadCtl.replace("addFileControl(_index_)", "addFileControl(1)");
                uploadCtl = uploadCtl.replace(new RegExp("uploadName", "gm"), "uploadName1");

                $("#tableAttach").append("<tr id='trAttach1' name='trAttach'>"
                                + "<td style='width: 10%; text-align:right'><a href='###' style='color:Red; font-size:12px' onclick='delFileControl(1)'>[删除]</a></td> "
                                 + "<td style='width:90%'>" + uploadCtl + "</td>"
                //+ "<input type='file' id='fileUpload1' name='attachUpload' onchange='addFileControl(1)' />"
                                + "</tr>");
            }
            else {
                $("tr[id='trAttach" + rowIndex + "']").remove(); //删除当前行
            }
        }
    </script>
</head>
<body>
    <div class="main">
        @using (Html.BeginForm("Save", "FTPManage", FormMethod.Post, new { id = "form_query" }))
        {
            @Html.Hidden("hdjsAlert", (ViewData["jsAlert"]));
                                                            
            <div class="content">
                @* <div class="left">
                    <div class="left-t">
                        <b>文件上传</b></div>
                    <div class="left-c">
                        @Html.Raw(ViewData["FFtpShowText"].ToString())
                    </div>
                </div>*@
                <div class="cont" style="width: 99%">
                    <table width="100%" border="0">
                        <tr>
                            <th colspan="4">
                                &nbsp;&nbsp;上传信息
                            </th>
                        </tr>
                        <tr>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px; text-align: right;">
                                报送单位:
                            </td>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px">
                                <input type="text" name="deptName" id="deptName"    value="@Model.FDeptName" disabled="disabled" style="border:#D4D0C8 1px solid; height:22px; line-height:22px;" title="@Model.FDeptName" />
                            </td>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px; text-align: right;">
                                联系电话:
                            </td>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px">
                                <input type="text" name="FLinkTel" id="FLinkTel" style="border:#D4D0C8 1px solid; height:22px; line-height:22px;" @Html.Raw(@ViewData["isdisable"].ToString()) value="@Model.FLinkTel" title="@Model.FLinkTel" />
                            </td>
                        </tr>
                        <tr>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px; text-align: right;">
                                类 型:
                            </td>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px" colspan="1">
                                <select name="FFTPType" id="FFTPType" style="width: 90%">
                                    @foreach (ElingOA6_Admin_DSJCJ.Model.SysBasicCodeName y in ViewData["SysBasicCodeName"] as List<ElingOA6_Admin_DSJCJ.Model.SysBasicCodeName>)
                                    {
                                        if (y.FCodeNo == Model.FFTPType)
                                        {
                                        <option selected="selected" value='@y.FCodeNo'>@y.FCodeName</option> 
                                        }
                                        else
                                        {
                                            if (string.IsNullOrEmpty(@ViewData["isdisable"].ToString()))
                                            {   <option  value='@y.FCodeNo'>@y.FCodeName</option> 
                                            }
                                        }
                                    }
                                </select>
                            </td>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px; text-align: right;">
                                联系人:
                            </td>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px">
                                <input style="border:#D4D0C8 1px solid; height:22px; line-height:22px;" type="text" name="FLinkMan"  id="FLinkMan" value="@Model.FLinkMan" @Html.Raw(@ViewData["isdisable"].ToString()) title="@Model.FLinkMan"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px; text-align: right;">
                                主 题:
                            </td>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px" colspan="3">
                                <input style="border:#D4D0C8 1px solid; height:22px; line-height:22px;" type="text" name="FSubject" id="FSubject"  style="width: 90%"  value="@Model.FSubject" @Html.Raw(@ViewData["isdisable"].ToString())  title="@Model.FSubject"  />
                            </td>
                        </tr>
                        <tr>
                            <td style="line-height: 40px; border: #A3C8E5 1px solid; padding-left: 10px; text-align: right;">
                                附 件:
                            </td>
                            <td colspan="3" valign="top" style="border-bottom: 2px solid #CCCCCC; border-right-style: solid;
                                border-bottom-style: solid; border-right-width: 1px; border-bottom-width: 1px;
                                border-right-color: #CCCCCC; border-bottom-color: #CCCCCC;">
                                <table width="100%">
                                    <tr>
                                        @if((bool)@ViewData["alllook"]) 
                                        {
                                        <th style="text-align: center">
                                            已上传文件
                                        </th>
                                        }
                                    </tr>
                                    <tr>
                                        <td>
                                            <table id="tblink" style="width: 90%">
                                                @{int idcount = 0;}
                                                @foreach (KeyValuePair<string, string> kv in attachfiles)
                                                {
                                                    idcount++;
                                                    string strid = "links" + idcount.ToString();
                                                    string strdel = "dellink(" + idcount.ToString() + ")";
                                                    if ((bool)@ViewData["alllook"])
                                                    {  <tr name="links" id="@strid">
                                                        <td colspan="2" height="40" style="border-bottom: 2px solid #CCCCCC; text-align: left;
                                                            width: 7%;">
                                                            <a href="#" style="color: Red; font-size: 12px" onclick="@strdel">[删除]</a>
                                                        </td>
                                                        <td style="width: 45%;border-bottom: 2px solid #CCCCCC; ">
                                                            &nbsp; &nbsp; &nbsp; <a href="@Url.Content("~/Index/AttachDownLoad?attachID=" + @kv.Key)" style="white-space: nowrap; width: 80%">
                                                                @kv.Value </a>
                                                            <br />
                                                        </td>
                                                    </tr> 
                                                    }
                                                    else
                                                    {
                                                    <tr>
                                                        <td colspan="2" width="10%" height="40">
                                                        </td>
                                                        <td>
                                                            &nbsp; &nbsp; &nbsp;<a href="@Url.Content("~/Index/AttachDownLoad?attachID=" + @kv.Key)" style="width: 80%; white-space: nowrap">
                                                                @kv.Value </a>
                                                            <br />
                                                        </td>
                                                    </tr> 
                                                    }
                                                }
                                            </table>
                                        </td>
                                    </tr>
                                    @if ((bool)@ViewData["alllook"])
                                    {   
                                        <tr>
                                            <th style="text-align: center">
                                                添加新文件
                                            </th>
                                        </tr>
                                        <tr>
                                            <td>
                                                <fieldset>
                                                    <legend></legend>
                                                    <table id="tableOldAttach" border="0" cellpadding="0" cellspacing="0">
                                                    </table>
                                                    <table id="tableAttach" class="tableForm" border="0" cellpadding="0" cellspacing="0">
                                                        <tr id="trAttach1" name='trAttach'>
                                                            <td style="width: 10%; text-align: right">
                                                                <a href="###" style="color: Red; font-size: 12px" onclick="delFileControl(1)">[删除]</a>
                                                            </td>
                                                            <td style="width: 90%">
                                                                @Html.DevExpress().UploadControl(
                            settings =>
                            {
                                settings.Name = "uploadName1";
                                settings.BrowseButton.Text = "浏览";
                                settings.ClearFileSelectionImage.ToolTip = "清除选择";
                                settings.ShowProgressPanel = false;
                                //settings.ValidationSettings.Assign(ElingOA6_Admin_DSJCJ.Common.UploadControlHelper.PicValidationSettings);
                                settings.ShowUploadButton = false;
                                settings.Width = 220;
                                settings.ClientSideEvents.TextChanged = "function(s,e){addFileControl(1)}";
                            }).GetHtml()
                                                            </td>
                                                            @*<td style="width: 60%">
                                                            </td>*@
                                                        </tr>
                                                    </table>
                                                </fieldset>
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </td>
                        </tr>
                        @if ((bool)@ViewData["alllook"])
                        {   <tr>
                            <td colspan="4" style="text-align: center;">
                                <input name="" type="button" onclick="sub()" class="button1" value="保存" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input name="" type="reset" class="button2" onclick="col()" value="返回" />
                            </td>
                        </tr>
                        }
                        else
                        {
                            <tr>
                                <td colspan="4" style="text-align: center;">
                                    <input name="" type="button" onclick="col()" class="button1" value="返回" />
                                </td>
                            </tr>
                        }
                    </table>
                </div>
            </div> 
            @Html.Hidden("hFEmplNo", ViewData["FEmplNo"]);     
            @Html.Hidden("hdeptNo", ViewData["deptNo"]);
            @Html.Hidden("hfid", Model.FID);
            @Html.Hidden("hdUploadCtl", @Html.Partial("UploadControlPartial").ToHtmlString()); //上传控件html  
            @Html.Hidden("haids", ViewData["attachids"])  ;    
            @Html.Hidden("holdaids", ViewData["attachids"])  ;
        }
    </div>
</body>
</html>
